<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="/wondershare/js/jquery.js"></script> 
<script src="/wondershare/js/jquery.cvbox.min.js"></script> 
<script src="/wondershare/js/utils.js"></script> 
<script src="/wondershare/js/topic.js"></script> 
<link href="/wondershare/styles/main.css" rel="stylesheet" type="text/css" />
<link href="/wondershare/styles/general.css" rel="stylesheet" type="text/css" />
<title>类别管理</title>
<script type="text/javascript">  
var imgPlus = new Image();
imgPlus.src = "/wondershare/images/menu_plus.gif";
function rowClicked(obj)
{
	// 当前图像
	var  img = obj;
	// 取得上二级tr>td>img对象
	obj = obj.parentNode.parentNode;
	// 整个分类列表表格
	var tbl = document.getElementById("list-table");
	// 当前分类级别
	var lvl = parseInt(obj.className);
	// 是否找到元素
	var fnd = false;
	var sub_display = img.src.indexOf('menu_minus.gif') > 0 ? 'none' : (Browser.isIE) ? 'block' : 'table-row' ;
// 遍历所有的分类
	for (i = 0; i < tbl.rows.length; i++)
	{
		var row = tbl.rows[i];
		if (row == obj)
		{
		// 找到当前行
		fnd = true;
		//document.getElementById('result').innerHTML += 'Find row at ' + i +"<br/>";
		}
		else
		{
			if (fnd == true)
			{
				var cur = parseInt(row.className);
				var icon = 'icon_' + row.id;
				if (cur > lvl)
				{
					row.style.display = sub_display;
					if (sub_display != 'none')
					{
						var iconimg = document.getElementById(icon);
						iconimg.src = iconimg.src.replace('plus.gif', 'minus.gif');
					}
				}
				else
				{
					fnd = false;
					break;
				}
			}
		}
	}

	for (i = 0; i < obj.cells[0].childNodes.length; i++)
	{
		var imgObj = obj.cells[0].childNodes[i];
		if (imgObj.tagName == "IMG" && imgObj.src != '/wondershare/images/menu_arrow.gif')
		{
			imgObj.src = (imgObj.src == imgPlus.src) ? '/wondershare/images/menu_minus.gif' : imgPlus.src;
		}
	}
}
//note 生成HTML
function createHtml( table, field_id, key_id ){
	$("#create_tip_"+key_id).html( '正在生成...' );
	$.get('../bin/docList_'+table+'.php?action=pub&TID='+table+'&field_id='+field_id+'&key_id='+key_id+'&ajax_pub=1',function(data){
		if( parseInt(data) == 1 ){
			$("#create_tip_"+key_id).html( '生成成功' );
		}else if( data == 'empty' ){
			document.location.href = '../bin/doc_'+table+'.php?field_id='+field_id+'&key_id='+key_id;
		}else{
			$("#create_tip_"+key_id).html( '生成失败' );
		}
	});
}
</script>
<style type="text/css">
catListTag {
	DISPLAY: none
}
.cvBoxShade {
	Z-INDEX: 2000; BACKGROUND: #ccc; LEFT: 0px; WIDTH: 100%; POSITION: absolute; TOP: 0px; HEIGHT: 0px
}
.cvBoxBorder {
	BORDER-RIGHT: #000000 0px solid; PADDING-RIGHT: 8px; BORDER-TOP: #000000 0px solid; PADDING-LEFT: 8px; FONT-SIZE: 12px; Z-INDEX: 2000; PADDING-BOTTOM: 8px; BORDER-LEFT: #000000 0px solid; WIDTH: 100%; PADDING-TOP: 8px; BORDER-BOTTOM: #000000 0px solid; POSITION: absolute; BACKGROUND-COLOR: #ccc
}
.cvBoxBorder A {
	COLOR: #486aaa; TEXT-DECORATION: none
}
.cvBoxBorder A:hover {
	COLOR: #c00; TEXT-DECORATION: none
}
.cvBoxTitleBar {
	WIDTH: 100%; LINE-HEIGHT: 27px; HEIGHT: 26px; BACKGROUND-COLOR: #eeeeee
}
.cvBoxTitleBarText {
	PADDING-LEFT: 10px; FONT-WEIGHT: bold; FLOAT: left; COLOR: #333
}
.cvBoxTitleBarClose {
	PADDING-RIGHT: 10px; FLOAT: right; COLOR: #3867af; FONT-FAMILY: Verdana
}

.cvBoxBody {
	WIDTH: 100%; BACKGROUND-COLOR: #ffffff
}

</style>
</head>
<body >
<h1>
<span class="action-span">
<a href="/wondershare/category.php?action=index&act=add&type=<{$type}>&w_type=<{$w_type}>">添加分类</a>
</span>

<{if $type == 2}>
<span class="action-span1">
<a href="/wondershare/products.php?action=index&web_type=<{$w_type}>"><{$web_info}>网站产品信息</a>

</span>
<span id="search_id" class="action-span1">  > 产品分类列表 </span>
<{else if $type == 1}>
<span class="action-span1">
<a href="/wondershare/article.php?action=index&w_type=<{$w_type}>"><{$web_info}>网站文章信息</a>
</span>
<span id="search_id" class="action-span1">  > <{$web_info}>网站文章分类列表 </span>
<{/if}>
<div style="clear:both"></div>
</h1>
<input type="hidden" name="web_info" id="web_info" value="<{$web_info}>"/>
<table width="80%" cellspacing="1" cellpadding="2" id="list-table" class="list-div">
<tbody>
  <tr>   
    <th align="left">名称</th>
	<th width="3%">ID</th>
    <th width="5%">排序</th>
    <{if $type == 1}> <th>文章数目</th> <{else if $type == 2}> <th>产品数量</th> <{/if}>
	<th width="9%">操作人员</th>	
	<{if $type == 2}><th>最后操作时间</th><{/if}>
	<th width="12%">生成时间</th>
	<th width="8%">生成状态</th>
	<th width="5%">预览</th>
    <th width="18%">操作</th>
  </tr>
  <{foreach from=$cat_info item=cat}>
  <{if $cat.cat_id !=0}>
  <tr align="center" class="<{$cat.level}>" id="<{$cat.level}>_<{$cat.cat_id}>">
    <td align="left" class="first-cell" >
      <{if $cat.is_leaf neq 1}>
      <img src="/wondershare/images/menu_minus.gif" id="icon_<{$cat.level}>_<{$cat.cat_id}>" width="9" height="9" border="0" style="margin-left:<{$cat.level}>em" onclick="rowClicked(this)" />
      <{else}>
      <img src="/wondershare/images/menu_arrow.gif" width="9" height="9" border="0" style="margin-left:<{$cat.level}>em" />
      <{/if}>
      <span><{$cat.cat_title|escape}></span>
    </td>
	
	<td><{$cat.cat_id}></td> 
	<td align="center" id="td_order_<{$cat.cat_id}>">
	<span onmouseout="check_css('sort_order_<{$cat.cat_id}>',0);" onmouseover="check_css('sort_order_<{$cat.cat_id}>',1);"      
	onclick="check_info(<{$w_type}>,'<{$cat.cat_id}>','sort_order_<{$cat.cat_id}>','td_order_<{$cat.cat_id}>',20,'sort');"  id="sort_order_<{$cat.cat_id}>" ><{$cat.sort_order}></span>
	</td>
	
	<td align="center" >
	<{if $type == 1}> 
	  <{if $cat.cat_series == 3}><a href="/wondershare/article.php?action=index&cat_id=<{$cat.cat_id}>&count=count&w_type=<{$w_type}>" style="text-decoration:underline; color:#FF0000" ><p id="count_<{$cat.cat_id}>"><{$cat.cat_count}></p></a><{else}>
	   <p id="count_<{$cat.cat_id}>"><{$cat.cat_count}></p>
	   <{/if}>
	<{else if $type == 2}>
	<p id="count_<{$cat.cat_id}>"><{$cat.ws_count}></p>
	<{/if}> 
	</td>
	
	<td align="center"><{$cat.add_user}></td>
	
	<{if $type == 2}> 
	<td align="center"> 
	 <{if $cat.update_time!=""}>
	  <{$cat.update_time}>
	 <{else}>
	   <{$cat.add_time}>
	 <{/if}> 
	 </td>
	<{/if}> 
	
   <td align="center"><{$cat.pub_time}></td>
   <td align="center" id="create_tip_<{$cat.cat_id}>"><span style="color:#FF0000"><{if $cat.pub_status == 1}> 已生成html<{/if}></span></td>
   <td align="center"><{if $cat.template_url neq '' && $cat.template_url neq '0' }> <a href="<{$cat.template_url}>"  target="_blank" >预览</a> <{/if}></td>
    <td align="center">
     <a href="#" onclick="{if(confirm('确定要删除记录吗?')){del_cat(<{$cat.cat_id}>,<{$type}>,<{$w_type}>);}return false;}" >删除</a> | 
	<a href="/wondershare/category.php?action=index&act=edit&cat_id=<{$cat.cat_id}>&type=<{$type}>&w_type=<{$w_type}>" > 编辑 </a>
	<{if $cat.cat_series == 3}>
	  <{if $cat.cat_type == 1}> 
       | <a href="<{if $cat.pub_status == 1}>javascript:createHtml(<{$site_config.table}>,<{$site_config.field_id}>,<{$cat.cat_id}>);<{else}>../bin/doc_<{$site_config.table}>.php?field_id=<{$site_config.field_id}>&key_id=<{$cat.cat_id}><{/if}>">生成</a>| 
      <a id="A4_<{$cat.cat_id}>" href="javascript:void(0);" onclick = 'select_check(<{$cat.cat_id}>,"topic")' >选择相关topic</a> 
	  <{/if}>
	  <{if $cat.cat_type == 2}> <{if $cat.is_c_mobile == 0}>| <a id="A5_<{$cat.cat_id}>" href="javascript:void(0);" onclick = 'select_check(<{$cat.cat_id}>,"ws_product")' >选择相关产品分类</a> 
	  <{/if}>
	  <{/if}>
	<{/if}>
    </td>
  </tr>
  <{if $cat.cat_series == 3}>
  <{if $cat.cat_type == 1}> 
   <div class="A4Demo_<{$cat.cat_id}>" style="display: none; width: 550px; padding: 10px;"  id="A4Demo_<{$cat.cat_id}>">
    <div id="A4Demo2_<{$cat.cat_id}>">
       <{$cat.cat_related}> <br />
	   <input type="button"    value="确定"  name="check_topic_<{$cat.cat_id}>"  id="check_topic_<{$cat.cat_id}>"  
        onclick="submit_select(<{$cat.cat_id}>,<{$type}>,'update_topic',<{$w_type}>);" style="margin-top:20px; margin-left:200px;">	   
     </div>
    </div>
    <{/if}>
	
	<{if $cat.cat_type == 2}> 
   <div class="A5Demo_<{$cat.cat_id}>" style="display: none; width: 550px; padding: 10px;"  id="A5Demo_<{$cat.cat_id}>">
    <div id="A5Demo2_<{$cat.cat_id}>">
	<{if $cat.cat_related == ''}>
	 <div><span style=" color:#FF0000; margin-left:220px;" >无相关产品</span></div>
	<{else}>
       <{$cat.cat_related}> <br />
	 <{/if}> 
	   <input type="button" value="确定" name="check_product_<{$cat.cat_id}>" id="check_product_<{$cat.cat_id}>" onclick="submit_select(<{$cat.cat_id}>,<{$type}>,'update_product',<{$w_type}>);" style="margin-top:20px; margin-left:200px;">
	  <input type="button"  value="取消选择" onclick="reset_radio(<{$cat.cat_id}>)"  name="reset_<{$cat.cat_id}>" style="margin-top:20px; margin-left:20px;" >
	 
     </div>
    </div>
	<{/if}> 
		
   <{/if}>
   <{/if}>
  <{/foreach}>
  </tbody>
</table>

<script type="text/javascript">  
function  reset_radio(id){
	$('input[name="product'+id+'"]').attr("checked",'');
}
function select_check(id,type)
{
	var web_info = $("#web_info").val();
	if(type == 'topic')
	{
		$(".A4Demo_"+id).cvbox(
		{
		titleBarText: "选择相关topic"
		});
		$('#A4Demo2_'+id).show();
	}else if(type == 'ws_product')
	{
		$(".A5Demo_"+id).cvbox(
		{
		titleBarText: "选择相关"+web_info+"产品分类"
		});
		$('#A5Demo2_'+id).show();
	}
} 

function  submit_select(id,type,action,w_type)
{
	var cat_str = '';
	var dir_demo = '';
	if(action == 'update_product')
	{
	dir_demo = 'A5Demo2_';
	cat_str = $('input[name="product'+id+'"][checked]').val();
	
	}else if(action == 'update_topic')
	{
		dir_demo = 'A4Demo2_';
		$('input[name="topic'+id+'[]"]').each(function () {
		if ($(this).attr('checked')) 
		{
			cat_str = cat_str + $(this).val()+',';
		}
		});
	}
	$.get("/wondershare/category.php?action=index", { in_jax: 1, cat_str: cat_str,cat_id:id,type:'update_cat_related' },
	function(data){
		$('#'+dir_demo+id).hide();
		$("#cvBoxTitleBarClose").click();	
		window.location.href="/wondershare/category.php?action=index&type="+type+"&w_type="+w_type;
	});
}
 </script>
</body>
</html>